Duktape API uses typedef-wrapped C types such as duk_int_t,
duk_idx_t, and duk_ret_t almost exclusively to ensure
portability to exotic platforms. On most platforms these map directly to signed
or unsigned int; the wrappers make it possible to support platforms
where usual type assumptions (like having a 32-bit int) don't hold.
See Wiki article API C types
for a detailed discussion.
Summary of best practices:
duk_idx_t and duk_ret_t
when declaring variables for maximum portability. Alternatively you may
use plain types (like long) but your code will be less portable
and you may need to use casts to avoid warnings.printf() and duk_push_sprintf() formatting
cast Duktape types to a wide integer type and use a standard format specifier.
Example: printf("Result: %ld\n", (long) duk_get_int(ctx, -3));.L (or UL) suffix for constants which
are larger than 16 bits to maximize portability. Like the int
type, integer constants without a suffix are only guaranteed to be 16 bits
wide. With the L suffix constants are guaranteed to be at least
32 bits wide. Example: duk_push_int(ctx, 1234567L);.